<template>
	<view class="page">
    <view class="news" v-for="(item,index) in news" :key="index" @click="navigator(item)">
			<image class="newsImg" :src="item.img"></image>
			<view class="newsBox" >
				<view class="tit">标题：{{ item.title }}</view>
				<view class="info">发布时间:{{ item.data }}</view>
			</view>
		</view>
	</view>
</template>

<script>
import { baseUrl } from '@/config'
export default {
	data() {
		return {
      nid:0,
      userinfo:[],
      news:[]
		};
	},
	onShow() {
    this.getNews()
	},
	methods: {
    navigator(item){
       this.nid = item.nid
       
      uni.navigateTo({
           url: `/pages/news-detail/index?nid=${this.nid}`
        });
    },
    getNews(){
      uni.request({
        url: baseUrl+'/v1/news/allSearch', 
        success: (res) => {
          this.news = res.data.data
        }
      });
    }
	}
};
</script>

<style lang="scss" scoped>
.page{
  .news{
    margin: 20rpx 20rpx;
		border-radius: 20rpx;
		display: flex;
		padding: 20rpx 20rpx;
		border:1px solid red;
    .newsImg{
			width: 150rpx;
			min-width: 150rpx;
			max-width: 150rpx;
			height: 150rpx;		
		}
		.newsBox{
			margin-left: 20rpx;
			display: flex;
			flex-direction: column;
			justify-content: space-between;
			border-radius: 20rpx;
      position: relative;
			.tit{
				font-size: 32rpx;
				color: #4d2a2a;
				border-radius: 20rpx;
			}
			.info{
				border-radius: 20rpx;
				font-size: 24rpx;
				color: #6b3939;
        position: absolute;
        bottom: 0;
        right: 0;
			}
		}
	}
}

</style>
